using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using ESBSimpleSamples.ServiceClient.Generator.Scripts;
using ESBSimpleSamples.ServiceClient.Generator.WSDL;
using ScintillaNet;

namespace ESBSimpleSamples.ServiceClient.Generator.Components
{
    public class ScriptTabPage : TabPage
    {
        private ScriptBase _script;
        private Scintilla _txtOutput;
        
        public ScriptTabPage(ScriptBase script)
        {
            this._script = script;
            this.Text = this._script.Name;
            this._txtOutput = new Scintilla();
            this.Controls.Add(this._txtOutput);
            this._txtOutput.Dock = DockStyle.Fill;            
        }

        public void PopulateFromWSDL(WSDLMetadata wsdl, WSDLMethod method)
        {
            this._script.Metadata = wsdl;
            this._script.Method = method;
            this._txtOutput.ConfigurationManager.Language = this._script.Language;
            this._script.Render();
            this._txtOutput.Text = this._script.Output.GetStringBuilder().ToString();
        }
    }
}
